// 核心数据类型定义

// 单词类型
export interface Word {
  id: string;
  text: string;
  definition: string;
  pronunciation: string;
  partOfSpeech: string;
  examples: string[];
  difficulty: 'beginner' | 'intermediate' | 'advanced';
  learned: boolean;
  correctPronunciations: number;
  totalAttempts: number;
}

// 场景类型
export interface Scene {
  id: string;
  words: string[];
  imageUrl: string;
  title: string;
  description: string;
  createdAt: Date;
  favorited: boolean;
  hotspots: Hotspot[];
  imagePrompt?: string; // AI 图像生成提示
  aiGenerated?: boolean; // 是否由 AI 生成
}

// 图片热点
export interface Hotspot {
  id: string;
  wordId: string;
  x: number; // 百分比位置
  y: number; // 百分比位置
  width: number;
  height: number;
}

// 学习会话
export interface LearningSession {
  id: string;
  sceneId: string;
  startTime: Date;
  endTime?: Date;
  wordsLearned: string[];
  pronunciationAttempts: number;
  correctPronunciations: number;
  score: number;
}

// 用户进度
export interface UserProgress {
  totalWordsLearned: number;
  totalScenesCreated: number;
  totalStudyTime: number; // 分钟
  currentStreak: number;
  longestStreak: number;
  achievements: Achievement[];
  level: number;
  experience: number;
}

// 成就系统
export interface Achievement {
  id: string;
  title: string;
  description: string;
  icon: string;
  unlockedAt?: Date;
  progress: number;
  maxProgress: number;
}

// 语音识别结果
export interface SpeechResult {
  transcript: string;
  confidence: number;
  accuracy: number;
}

// 应用状态
export interface AppState {
  currentScene?: Scene;
  selectedWords: string[];
  isGeneratingScene: boolean;
  learningMode: 'input' | 'scene' | 'learning';
  userProgress: UserProgress;
  savedScenes: Scene[];
  voiceEnabled: boolean;
  language: 'en' | 'zh';
}

// 单词建议
export interface WordSuggestion {
  word: string;
  frequency: number;
  category: string;
}

// API响应类型
export interface SceneGenerationResponse {
  success: boolean;
  sceneId: string;
  imageUrl: string;
  hotspots: Hotspot[];
  error?: string;
}

// 本地存储键
export const STORAGE_KEYS = {
  USER_PROGRESS: 'ai_english_user_progress',
  SAVED_SCENES: 'ai_english_saved_scenes',
  LEARNED_WORDS: 'ai_english_learned_words',
  SETTINGS: 'ai_english_settings',
  ACHIEVEMENTS: 'ai_english_achievements'
} as const;